package com.menhai.personmanagement.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.menhai.personmanagement.entity.PatientsWithDetail;
import com.menhai.personmanagement.services.PatientsWithDetailService;
import com.menhai.personmanagement.utils.ExportSysPatientsWithDetailInfoExcel;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
@RequestMapping("/PatientsWithDetail")
public class PatientsWithDetailController {
	@Autowired
	private PatientsWithDetailService PatientsWithDetailService;
	
	@RequestMapping("/selectQuery")
	public List<PatientsWithDetail> selectQuery (PatientsWithDetail PatientsWithDetail){
		List<PatientsWithDetail> PatientsWithDetailList = new ArrayList<PatientsWithDetail>();
		PatientsWithDetailList = PatientsWithDetailService.selectQuery(PatientsWithDetail);
        return PatientsWithDetailList;
   }
	
	@GetMapping("/export")
    public void exports(HttpServletResponse response){
        try {
            List<PatientsWithDetail> list = new ArrayList<>();
            ServletOutputStream out = response.getOutputStream();
            new ExportSysPatientsWithDetailInfoExcel().export(list, out, response);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
